<%--
  ~ Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
  ~ Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
  ~ Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
  ~ Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
  ~ Vestibulum commodo. Ut rhoncus gravida arcu.
  --%>

<%--
  Created by IntelliJ IDEA.
  User: dengdc
  Date: 2017/7/19
  Time: 17:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="s" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>编辑</title>
    <jsp:include page="../../head.jsp"/>
    <script type="text/javascript">
        var formSetting = {
            title: "编辑报价",
            module: 'save',
            columns: [
                {
                    name: "id",
                    hidden: true
                }, {
                    name: "uniteId",
                    hidden: true,
                    value: "${param.uniteId}"
                }, {
                    name: "name",
                    label: "费用名称",
                    validate:'validate[required]'
                }, {
                    name: "bizType",
                    label: "业务类型",
                    type: "dropdown",
                    dropdownType: "ajax",
                    url: "<s:url value='/api/dictionary/getJsonByCodes?codes='/>" + encodeURI(
                        "{'codes':['protocol_biz_type']}"),
                    op: "eq",
                    minLength: 0,
                    keyWordName: "key",
                    success: function (data) {
                        data = data.content[0].protocol_biz_type;
                        var array = new Array();
                        $.each(data, function (i, n) {
                            array.push([n["dtName"], n["dtId"]]);
                        });
                        return array;
                    },
                    validate:'validate[required]'
                }, {
                    name: "feeType",
                    label: "费用类型",
                    type: "dropdown",
                    dropdownType: "ajax",
                    url: "<s:url value='/api/dictionary/getJsonByCodes?codes='/>" + encodeURI(
                        "{'codes':['protocol_fee_type']}"),
                    op: "eq",
                    minLength: 0,
                    keyWordName: "key",
                    success: function (data) {
                        var array = [];
                        var contentData = data.content[0];
                        for (var ky in contentData) {
                            var sdata = contentData[ky];
                            $.each(sdata, function (i, n) {
                                array.push([n["dtName"], n["dtId"]]);
                            });
                        }
                        return array;
                    },
                    validate:'validate[required]'
                }, {
                    name: "countRule",
                    label: "计算规则",
                    type: "dropdown",
                    dropdownType: "ajax",
                    url: "<s:url value='/api/dictionary/getJsonByCodes?codes='/>" + encodeURI(
                        "{'codes':['protocol_count_fee_rule']}"),
                    op: "eq",
                    minLength: 0,
                    keyWordName: "key",
                    success: function (data) {
                        var array = [];
                        for (var i = 0; i < data.content.length; i++) {
                            var contentData = data.content[i];
                            for (var ky in contentData) {
                                var sdata = contentData[ky];
                                $.each(sdata, function (i, n) {
                                    array.push([n["dtName"], n["dtId"]]);
                                });
                            }
                        }
                        return array;
                    },
                    validate:'validate[required]'
                }, {
                    name: "ieType",
                    label: "进出口类型",
                    type: "dropdown",
                    dropdownType: "ajax",
                    url: "<s:url value='/api/dictionary/getJsonByCodes?codes='/>" + encodeURI(
                        "{'codes':['ie_type']}"),
                    op: "eq",
                    minLength: 0,
                    keyWordName: "key",
                    success: function (data) {
                        var array = [];
                        for (var i = 0; i < data.content.length; i++) {
                            var contentData = data.content[i];
                            for (var ky in contentData) {
                                var sdata = contentData[ky];
                                $.each(sdata, function (i, n) {
                                    array.push([n["dtName"], n["dtId"]]);
                                });
                            }
                        }
                        return array;
                    },
                    validate:'validate[required]'
                }, {
                    name: "dntType",
                    label: "直转类型",
                    type: "dropdown",
                    dropdownType: "ajax",
                    url: "<s:url value='/api/dictionary/getJsonByCodes?codes='/>" + encodeURI(
                        "{'codes':['direct_transit_type']}"),
                    op: "eq",
                    minLength: 0,
                    keyWordName: "key",
                    success: function (data) {
                        var array = [];
                        for (var i = 0; i < data.content.length; i++) {
                            var contentData = data.content[i];
                            for (var ky in contentData) {
                                var sdata = contentData[ky];
                                $.each(sdata, function (i, n) {
                                    array.push([n["dtName"], n["dtId"]]);
                                });
                            }
                        }
                        return array;
                    },
                    validate:'validate[required]'
                }, {
                    name: "startCount",
                    label: "起算数量",
                    validate:'validate[required]'
                }, {
                    name: "unitPrice",
                    label: "单价",
                    validate:'validate[required]'
                }, {
                    name: "unitPriceOut",
                    label: "单价成本",
                    validate:'validate[required]'
                }, {
                    name: "capPrice",
                    label: "封顶价"
                }
                ,  {
                    name: "capPriceOut",
                    label: "封顶价成本"
                }, {
                    name: "descript",
                    label: "描述",
                    type: 'textarea',
                    colspan: 3
                }],
            form: {
                'url': 'saveOrUpdate',
                'data': function () {
                    var dataValue = "";
                    $.ajax({
                               url: "editData?id=${param.id}",
                               async: false,
                               success: function (data) {
                                   dataValue = data;
                               }
                           });
                    return dataValue;
                },
                'ajaxForm': {
                    success: function (result) {
                        $("#saveButton").attr("disabled","disabled");
                        parent.layer.msg(result.msg);
                        parent.reloadGridData();
                        parent.closeEditView();
//                        location.herf = "add?dtgId="  + result.data;
                    }
                }
            },
            buttons: {
                custom: []
            }
        };
        $(document).ready(function () {
            $("#table").mrdForm(formSetting);
        });
    </script>
</head>
<body>
<div id="table"></div>
</body>
</html>
